package com.lxf.cloudotherserve.mapper;

import com.lxf.cloudotherserve.bean.PlayHistoryBean;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Component;

/**
 * @author 罗兴发
 * @data 2025/6/23 11:54
 * @description：es持久层
 */
@Component
public interface PlayHistoryItemRepository extends ElasticsearchRepository<PlayHistoryBean, String> {
    /**
     * 根据用户ID查询浏览记录
     * @param userId 用户ID
     * @param pageable 分页对象
     * @return 返回分页结果集
     */
    Page<PlayHistoryBean> findAllByUserIdOrObjTitleIsLike(Integer userId,String content, Pageable pageable);

    /**
     * 根据内容ID查询浏览记录
     * @param objId 对象ID
     * @param type 对象类型
     * @param pageable 分页对象
     * @return 返回分页结果集
     */
    Page<PlayHistoryBean> findAllByObjIdAndPhTypeOrObjTitleIsLike(String objId,Integer type, String content, Pageable pageable);

    /**
     * 根据ID和类型删除
     * @param type
     * @param objId
     * @return
     */
    int deleteByObjIdAndPhType(Integer type,String objId);
}